const path = require('path');
// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const webpack = require('webpack')
const productionGzipExtensions = ['js', 'css']
module.exports = {
    productionSourceMap: false,
    devServer:{
        // liveReload: false,  //刷新页面
        port:1025,
        disableHostCheck:true,  //打开方便本地host代理调试,
        open:true,
        proxy:{
            '/dev':{
                // target: 'http://performance.xhhg.test/',
                target: 'http://192.168.2.20:81',
                changeOrigin: true,  /*将主机标头的原点更改为目标URL*/
                ws: true,       /*是否代理websockets*/
                secure: false,  /*是否验证SSL Certs*/
                pathRewrite: {
                    '^/dev': '',
                }
            },
        }
    },

    chainWebpack: (config) => {
        config.optimization.minimize(true)
        // config.externals({
        //     'echarts': 'echarts',
        // });
    },
    configureWebpack: {
        plugins: [
            // new BundleAnalyzerPlugin(),
            new CompressionWebpackPlugin({
                algorithm: 'gzip',
                test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
                threshold: 10240,
                minRatio: 0.8
            }),
            new webpack.optimize.LimitChunkCountPlugin({
                maxChunks: 5, 
                minChunkSize: 100
            })
        ]
    }
};
